home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / epsfig / epsfig.2e < prev    next >
Text File  |  1994-01-26  |  49KB  |  1,338 lines

  1. %----------------------------------------------
  2. \NeedsTeXFormat{LaTeX2e}
  3. \def\fileversion{2}%
  4. \def\filedate{1994/01/25}%
  5. \ProvidesPackage{epsfig}[\filedate]
  6. \message{ Epsfig }
  7. % minimal reworking for LaTeX2e!
  8. % this will be all be rewritten when the LaTeX2e includegraphics
  9. % comes out.
  10. %
  11. % SPQR Jan 94
  12. %
  13. %%%--------------------------------------------------------------------
  14. %%% psfig merged with EPSF = epsfig Release 1
  15. %%% 1.0 November 91
  16. %%% 1.1 Dec 91  fixed some bugs
  17. %%% 1.2 Jan 92  fixed bug that it never stopped reading PS file until
  18. %%%             it reached the end! merged in changes from psfig1.8
  19. %%%             (plain TeX definition of \fbox, new code for rotation)
  20. %%% 1.3 Jan 92  separated out \special code so that dvitops can be
  21. %%%             supported. use \psfigdriver{dvitops}%
  22. %%% 1.4 Jan 92  fixed dvitops. need to input psfig at different point
  23. %%%      in dvips from dvitops. define \psfig@start and \psfig@end to cope
  24. %%%      with this
  25. %%% 1.5 Jan 92  force use of psfig method if using dvitops
  26. %%% 1.6 May 92 fixed bugs
  27. %%% 1.7 Sep 92 added support for emtex, sort of. reads a .bb file
  28. %%%            and imports .pcx file. Boolean flag \epsfigdos used
  29. %%%             to indicate that we cannot have more than one . in the
  30. %%%             suffix (ie we will look at file.bb not file.eps.bb)
  31. %%%
  32. %%% 1.8 Sep 92 added support for OzTeX; fixed bugs in dvips support
  33. %%% (including clipping to bounding box); removed use of dimen100.
  34. %%%
  35. %%% 1.9 Dec 92 cleaned up documentation again
  36. %%% 1.10 Mar 93 cleaned up for plain TeX
  37. %%% 1.11 Mar 93 merged in changes by Peter Galko (supplied by CERN) for
  38. %%%             use with Textures
  39. %%% 1.12 Apr 93 actually *tested* the Textures additions, and so rewrote
  40. %%%            from scratch (borrowed an idea from psbox)
  41. %%% 1.13 May 93 allow for file names with _ or $ in them in \psdraft, and
  42. %%%             fix problem that occurred with missing BoundingBox
  43. %%% 1.14 May 93 allow for .z suffix
  44. %%% 1.15 July 93 allow for .gz suffix
  45. %%%              use \leavevmode as appropriate
  46. %%%              fix plain \TeX mode 
  47. %%%             (fixes from Peter-Klaus Schilling <R02SCH@DSYIBM.DESY.DE>)
  48. %%% 1.16 August 93 [peta@mcrcim.mcgill.edu (Peter Whaite)]
  49. %%%        -- Implement Perl scripts to do compressed file inclusion and bb
  50. %%%           generation. 
  51. %%%        -- Add \pscompress.
  52. %%%        -- Tidy up comments.
  53. %%% 1.17 September 93 SPQR
  54. %%%     better code for literal name printing
  55. %%%     allowed for spaces around , and =
  56. %%% 1.18 17.9.93
  57. %%%   updates to epsbb and epsfig from Peter W
  58. %%% 1.19 14.11.93
  59. %%%   mistaken placement of calculation of EPS@Height resulted in errors
  60. %%%
  61. %--------------------------------------------------------
  62. %%%
  63. %%% code rearranged by Sebastian Rahtz (spqr@uk.ac.york.minster)
  64. %%% from work by
  65. %%% Trevor Darrell; Tom Rokicki; Daniel Smith; H. Payne, Robert Russell
  66. %%%
  67. %%% This is a version of Darrell's `psfig' macros which are designed
  68. %%% to be used with dvips or dvitops, and the `epsf' macros (these are
  69. %%% automaticaly included by the style file). I did this because the
  70. %%% \special commands used by `epsf' appear to be more robust and
  71. %%% portable than the raw \specials used by `psfig', but I preferred
  72. %%% the psfig interface. This system preserves the psfig interface,
  73. %%% but mainly uses epsf macros to carry out the job. The user
  74. %%% interface is identical to \psfig, but you just use \epsfig
  75. %%% instead. Rotation uses the original psfig macros: I could not work
  76. %%% out how to do rotation with the epsf macros.
  77. %%%
  78. %%% The same applies to `rheight' and `rwidth'
  79. %%%
  80. %%% If you *really* want old psfig behaviour regardless, use \psfig. It is
  81. %%% still there. Some of the features have gone, however. \figurepath
  82. %%% seemed redundant, since it could be controlled by the TEXINPUTS
  83. %%% variable anyway.
  84. %%%
  85. %%% As an added feature, if FILE cannot be found, a file called FILE.bb
  86. %%% is searched for. This should simply contain a %%BoundingBox line. A perl
  87. %%% script "epsbb" is provided to generate these automatically.  It is
  88. %%% assumed that if this exists, then the actual postscript is in UNIX
  89. %%% compress format in FILE.Z or in GNU gzip format in FILE.gz or FILE.z.
  90. %%%
  91. %%% The macros then read the BB from FILE.bb, but insert "`epsfig FILE`" in
  92. %%% the  output for dvips to interpret (don't worry, it knows about this).
  93. %%% "Epsfig" is another perl script which  searches the TEXINPUTS path for
  94. %%% FILE or FILE.{gz,z,Z}.
  95. %%%
  96. %%% As an added bonus if you say \pscompress the -c switch will be passed to
  97. %%% epsfig, causing automatic FILE.bb generation and compression the first
  98. %%% time dvips is run.  Files in the system directories will NOT be
  99. %%% compressed.
  100. %%% If you are *not* on a Unix system and use this, deliberately or by
  101. %%% mischance, you will have problems!
  102. %%%
  103. %%% This file can be included in a dumped format, or used as a LaTeX
  104. %%% style file, or used in plain TeX. It does not load itself twice (I hope)
  105. %%%
  106. %--------------------------------------------------------------------
  107. %--------------------------------------------------------------------
  108. %%% previous notes. this copy of psfig.tex inherited from versions 1.8
  109. %--------------------------------------------------------------------
  110. %%% All psfig/tex software, documentation, and related files
  111. %%% in this distribution of psfig/tex are
  112. %%% Copyright 1987, 1988, 1991 Trevor J. Darrell
  113. %
  114. %%% Permission is granted for use and non-profit distribution of psfig/tex
  115. %%% providing that this notice be clearly maintained. The right to
  116. %%% distribute any portion of psfig/tex for profit or as part of any commercial
  117. %%% product is specifically reserved for the author(s) of that portion.
  118. %%%
  119. %%% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions
  120. %%% to this project.
  121. %%%--------------------------------------------------------------------------
  122. %%% GDH 7/26/87 -- changed so that it first looks in the local directory,
  123. %%% then in a specified global directory for the ps file.
  124. %%% SPQR 12/91 removed that last change. it follows TEXINPUTS anyway
  125. %%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if
  126. %%% boundingbox info is specified, assuming graphic will be created by
  127. %%% print time.
  128. %%% SPQR 12/91 removed that last change. use LaTeX error message instead
  129. %%% SPQR 12/91 -- `no file found' produces LaTeX error message.
  130. %%%                If you recover from that the file name is set in draft
  131. %%%                mode in place of the file.
  132. %%%
  133. %%% Modified by J. Daniel Smith on 9 October 1990 to accept the
  134. %%% %%BoundingBox: comment with or without a space after the colon.  Stole
  135. %%% file reading code from Tom Rokicki's EPSF.TEX file (see below).
  136. %%% --- SPQR 12.91 removed most of this to use epsf directly
  137. %%%
  138. %%% More modifications by J. Daniel Smith on 29 March 1991 to allow the
  139. %%% the included PostScript figure to be rotated.  The amount of
  140. %%% rotation is specified by the "angle=" parameter of the \epsfig command.
  141. %%%
  142. %%% Modified by Robert Russell on June 25, 1991 to allow users to specify
  143. %%% .ps filenames which don't yet exist, provided they explicitly provide
  144. %%% boundingbox information via the \epsfig command. Note: This will only work
  145. %%% if the "file=" parameter follows all four "bb???=" parameters in the
  146. %%% command. This is due to the order in which psfig interprets these params.
  147. %%% ---- SPQR 12.91 removed all this
  148. %%%
  149. %%% 3 Jul 1991  JDS     check if file already read in once
  150. %%%
  151. %-----------------------------USAGE---------------------------------------
  152. % From: gvr@cs.brown.edu (George V. Reilly)
  153. %
  154. % \psdraft      draws an outline box, but doesn't include the figure
  155. %               in the DVI file.  Useful for previewing.
  156. %
  157. % \psfull       includes the figure in the DVI file (default).
  158. %
  159. % \psscalefirst width= or height= specifies the size of the figure
  160. %               before rotation.
  161. % \psrotatefirst (default) width= or height= specifies the size of the
  162. %                figure after rotation.  Asymetric figures will
  163. %                appear to shrink.
  164. %
  165. % usage: \epsfig{file=, figure=, height=, width=,
  166. %                       bbllx=, bblly=, bburx=, bbury=,
  167. %                       rheight=, rwidth=, clip=, angle=, silent=}%
  168. %
  169. %       "file" is the filename.  If no path name is specified and the
  170. %               file is not found in the current directory,
  171. %               it will be looked for in directory \psfigurepath.
  172. %       "figure" is a synonym for "file".
  173. %       By default, the width and height of the figure are taken from
  174. %               the BoundingBox of the figure.
  175. %       If "width" is specified, the figure is scaled so that it has
  176. %               the specified width.  Its height changes proportionately.
  177. %       If "height" is specified, the figure is scaled so that it has
  178. %               the specified height.  Its width changes proportionately.
  179. %       If both "width" and "height" are specified, the figure is scaled
  180. %               anamorphically.
  181. %       "bbllx", "bblly", "bburx", and "bbury" control the PostScript
  182. %               BoundingBox.
  183. %       "rheight" and "rwidth" are the reserved height and width
  184. %               of the figure, i.e., how big TeX actually thinks
  185. %               the figure is.  They default to "width" and "height".
  186. %       The "clip" option ensures that no portion of the figure will
  187. %               appear outside its BoundingBox.  "clip=" is a switch and
  188. %               takes no value, but the `=' must be present.
  189. %       The "angle" option specifies the angle of rotation (degrees, ccw).
  190. %       The "silent" option makes \psfig work silently.
  191. %
  192. %--------------------------------------------------------------------------
  193. %%% if this is true, the original Darrell macros and specials are used
  194. \newif\ifuse@psfig
  195. \use@psfigtrue
  196. \newcount\EPS@Height \newcount\EPS@Width \newcount\EPS@xscale
  197. \newcount\EPS@yscale
  198. \def\psfig@start{\typeout{EPSFIG - driver}}
  199. \def\psfig@end{\typeout{EPSFIG - driver}}
  200. \def\epsfig@gofer{\typeout{EPSFIG - driver}}
  201. \newcount\fig@driver
  202. \DeclareOption{ln03}{
  203. \typeout{WARNING! ****
  204.  no specials for LN03 epsfig}%
  205. }
  206. \DeclareOption{dvitops}{%
  207.  \use@psfigtrue
  208.  \def\psfig@start{}%
  209.  \def\psfig@end{\special{dvitops: import \@p@sfilefinal \space
  210.  \@p@swidth sp \space \@p@sheight sp \space fill}%
  211.  \if@clip \typeout{Clipping not supported}\fi
  212.  \if@angle \typeout{Rotating not supported}\fi}
  213.  \let\epsfig@gofer\psfig@end
  214. }
  215.  
  216. \DeclareOption{dvips}{%
  217.  \message{(dvips)}%
  218.  \use@psfigfalse
  219.  \def\psfig@start{
  220.     \message{ what are \@p@swidth, and \@p@sheight}%
  221.     \special{ps::[begin]  \@p@swidth \space \@p@sheight \space%
  222.         \@p@sbbllx \space \@p@sbblly \space%
  223.         \@p@sbburx \space \@p@sbbury \space%
  224.         startTexFig \space }%
  225.         \if@angle
  226.                 \special {ps:: \@p@sangle \space rotate \space}
  227.         \fi
  228.         \if@clip
  229.                 \if@verbose
  230.                         \typeout{(clipped to BB) }%
  231.                 \fi
  232.                 \special{ps:: doclip \space }%
  233.         \fi
  234.         \special{ps: plotfile \@p@sfilefinal \space }%
  235.         \special{ps::[end] endTexFig \space }%
  236.   }%
  237.   \def\psfig@end{}%
  238.   \def\epsfig@gofer{
  239.                    \if@clip
  240.                         \if@verbose
  241.                            \typeout{(clipped to BB)}%
  242.                         \fi
  243.                         \epsfclipon
  244.                   \fi
  245.                   \epsfsetgraph{\@p@sfilefinal}%
  246.  }
  247. }
  248.  
  249. \DeclareOption{emtex}{%
  250.  \use@psfigtrue
  251.  \fig@driver3
  252.  \Typeout{WARNING. You must have a .bb info file with the Bounding Box
  253.   of the pcx file}%
  254.  \def\psfig@start{}%
  255.  % when emtex imports a pcx file, it is *below* where we are now.
  256.  % so raise the box
  257.  \def\psfig@end{\typeout{pcx import of \@p@sfilefinal}%
  258.  \if@clip \typeout{Clipping not supported}\fi
  259.  \if@angle \typeout{Rotating not supported}\fi
  260.  \raisebox{\@p@srheight sp}{\special{em: graph \@p@sfilefinal}}}%
  261.  \def\epsfig@gofer{}%
  262. }
  263.  
  264. \DeclareOption{oztex}{%
  265.  \use@psfigtrue
  266.  \message{(OzTeX)}%
  267.  \def\psfig@start{}%
  268.  \def\psfig@end{%
  269.   \EPS@Width\@p@swidth
  270.   \EPS@Height\@p@sheight
  271.   \divide\EPS@Width by 65781  % convert sp to bp
  272.   \divide\EPS@Height by 65781
  273.   \special{epsf=\@p@sfilefinal
  274.   \space
  275.   width=\the\EPS@Width
  276.   \space
  277.   height=\the\EPS@Height
  278.  }%
  279.  \if@clip \typeout{Clipping not supported}\fi
  280.  \if@angle \typeout{Rotating not supported}\fi
  281.  }%
  282.  \let\epsfig@gofer\psfig@end 
  283. }
  284. \DeclareOption{textures}{%
  285.  \message{(Textures)}%
  286.  \use@psfigtrue
  287.  \def\psfig@end{
  288.  % what is scaling of picture
  289.          \EPS@Width=\@bbw  
  290.          \divide\EPS@Width by 1000
  291.          \EPS@xscale=\@p@swidth \divide \EPS@xscale by \EPS@Width
  292.          \EPS@Height=\@bbh  
  293.          \divide\EPS@Height by 1000
  294.          \EPS@yscale=\@p@sheight \divide \EPS@yscale by\EPS@Height
  295.  % take largest calculated scale
  296.   \ifnum\EPS@xscale>\EPS@yscale\EPS@xscale=\EPS@yscale\fi
  297.   \if@clip
  298.    \if@verbose
  299.       \typeout{(clipped to BB)}%
  300.    \fi
  301.    \epsfclipon
  302.  \fi
  303.  \special{illustration \@p@sfilefinal\space scaled \the\EPS@xscale}%
  304.  }%
  305.  \def\psfig@start{}%
  306. }
  307. \ProcessOptions
  308.  
  309. % copies of bits of LaTeX we need....
  310. \newdimen\ps@dimcent
  311. %
  312. % \fbox is defined in latex.tex; so if \fbox is undefined, assume that
  313. % we are not in LaTeX.
  314. % Perhaps this could be done better???
  315. \ifx\undefined\fbox
  316. % \fbox code from modified slightly from LaTeX
  317. \newdimen\fboxrule
  318. \newdimen\fboxsep
  319. \newdimen\ps@tempdima
  320. \newbox\ps@tempboxa
  321. \fboxsep = 0pt
  322. \fboxrule = .4pt
  323. \long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule
  324.     \advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa
  325.    \hbox{\lower \ps@tempdima\hbox
  326.   {\vbox{\hrule height \fboxrule
  327.           \hbox{\vrule width \fboxrule \hskip\fboxsep
  328.           \vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip
  329.                  \fboxsep\vrule width \fboxrule}%
  330.                  \hrule height \fboxrule}}}}%
  331. \fi
  332. \ifx\@ifundefined\undefined
  333. \long\def\@ifundefined#1#2#3{\expandafter\ifx\csname
  334.   #1\endcsname\relax#2\else#3\fi}%
  335. \fi
  336. %
  337. \@ifundefined{typeout}%
  338. {\gdef\typeout#1{\immediate\write\sixt@@n{#1}}}%
  339. {\relax}%
  340. %
  341. %%% check to see if macros already loaded in (maybe some other file says
  342. %%% "\input epsfig") ...
  343. \@ifundefined{epsfig}{}{\typeout{EPSFIG --- already loaded}\endinput}%
  344. %
  345. %%%
  346. %%% we need Rokicki's EPSF macros anyway:
  347. %
  348. %   EPSF.TEX macro file:
  349. %   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
  350. %   Revised by Don Knuth, 3 Jan 1990.
  351. %   Revised by Tomas Rokicki to accept bounding boxes with no
  352. %      space after the colon, 18 Jul 1990.
  353. %
  354. %   TeX macros to include an Encapsulated PostScript graphic.
  355. %   Works by finding the bounding box comment,
  356. %   calculating the correct scale values, and inserting a vbox
  357. %   of the appropriate size at the current position in the TeX document.
  358. %
  359. %   To use with the center environment of LaTeX, preface the \epsffile
  360. %   call with a \leavevmode.  (LaTeX should probably supply this itself
  361. %   for the center environment.)
  362. %
  363. %   To use, simply say
  364. %   \input epsf           % somewhere early on in your TeX file
  365. %   \epsfbox{filename.ps} % where you want to insert a vbox for a figure
  366. %
  367. %   Alternatively, you can type
  368. %
  369. %   \epsfbox[0 0 30 50]{filename.ps} % to supply your own BB
  370. %
  371. %   which will not read in the file, and will instead use the bounding
  372. %   box you specify.
  373. %
  374. %   The effect will be to typeset the figure as a TeX box, at the
  375. %   point of your \epsfbox command. By default, the graphic will have its
  376. %   `natural' width (namely the width of its bounding box, as described
  377. %   in filename.ps). The TeX box will have depth zero.
  378. %
  379. %   You can enlarge or reduce the figure by saying
  380. %     \epsfxsize=<dimen> \epsfbox{filename.ps}
  381. %   (or
  382. %     \epsfysize=<dimen> \epsfbox{filename.ps})
  383. %   instead. Then the width of the TeX box will be \epsfxsize and its
  384. %   height will be scaled proportionately (or the height will be
  385. %   \epsfysize and its width will be scaled proportiontally).  The
  386. %   width (and height) is restored to zero after each use.
  387. %
  388. %   A more general facility for sizing is available by defining the
  389. %   \epsfsize macro.    Normally you can redefine this macro
  390. %   to do almost anything.  The first parameter is the natural x size of
  391. %   the PostScript graphic, the second parameter is the natural y size
  392. %   of the PostScript graphic.  It must return the xsize to use, or 0 if
  393. %   natural scaling is to be used.  Common uses include:
  394. %
  395. %      \epsfxsize  % just leave the old value alone
  396. %      0pt         % use the natural sizes
  397. %      #1          % use the natural sizes
  398. %      \hsize      % scale to full width
  399. %      0.5#1       % scale to 50% of natural size
  400. %      \ifnum#1>\hsize\hsize\else#1\fi  % smaller of natural, hsize
  401. %
  402. %   If you want TeX to report the size of the figure (as a message
  403. %   on your terminal when it processes each figure), say `\epsfverbosetrue'.
  404. %
  405. \newread\epsffilein    % file to \read
  406. \newif\ifepsffileok    % continue looking for the bounding box?
  407. \newif\ifepsfbbfound   % success?
  408. \newif\ifepsfverbose   % report what you're making?
  409. \newif\ifepsfdraft     % use draft mode?
  410. \newdimen\epsfxsize    % horizontal size after scaling
  411. \newdimen\epsfysize    % vertical size after scaling
  412. \newdimen\epsftsize    % horizontal size before scaling
  413. \newdimen\epsfrsize    % vertical size before scaling
  414. \newdimen\epsftmp      % register for arithmetic manipulation
  415. \newdimen\pspoints     % conversion factor
  416. %
  417. \pspoints=1bp          % Adobe points are `big'
  418. \epsfxsize=0pt         % Default value, means `use natural size'
  419. \epsfysize=0pt         % ditto
  420. %
  421. \def\epsfbox#1{\global\def\epsfllx{72}\global\def\epsflly{72}%
  422.    \global\def\epsfurx{540}\global\def\epsfury{720}%
  423.    \def\lbracket{[}\def\testit{#1}\ifx\testit\lbracket
  424.    \let\next=\epsfgetlitbb\else\let\next=\epsfnormal\fi\next{#1}}%
  425. %
  426. \def\epsfgetlitbb#1#2 #3 #4 #5]#6{\epsfgrab #2 #3 #4 #5 .\\%
  427.    \epsfsetgraph{#6}}%
  428. %
  429. \def\epsfnormal#1{\epsfgetbb{#1}\epsfsetgraph{#1}}%
  430. %
  431. \def\epsfgetbb#1{%
  432. %
  433. %   The first thing we need to do is to open the
  434. %   PostScript file, if possible.
  435. %
  436. \openin\epsffilein=#1
  437. \ifeof\epsffilein\errmessage{I couldn't open #1, will ignore it}\else
  438. %
  439. %   Okay, we got it. Now we'll scan lines until we find one that doesn't
  440. %   start with %. We're looking for the bounding box comment.
  441. %
  442.    {\epsffileoktrue \chardef\other=12
  443.     \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10
  444.     \loop
  445.        \read\epsffilein to \epsffileline
  446.        \ifeof\epsffilein\epsffileokfalse\else
  447. %
  448. %   We check to see if the first character is a % sign;
  449. %   if not, we stop reading (unless the line was entirely blank);
  450. %   if so, we look further and stop only if the line begins with
  451. %   `%%BoundingBox:'.
  452. %
  453.           \expandafter\epsfaux\epsffileline:. \\%
  454.        \fi
  455.    \ifepsffileok\repeat
  456.    \ifepsfbbfound\else
  457.     \ifepsfverbose\message{No bounding box comment in #1; using defaults}\fi\fi
  458.    }\closein\epsffilein\fi}%
  459. %
  460. %   Now we have to calculate the scale and offset values to use.
  461. %   First we compute the natural sizes.
  462. %
  463. \def\epsfclipon{\def\epsfclipstring{ clip}}%
  464. \def\epsfclipoff{\def\epsfclipstring{\ifepsfdraft\space clip\fi}}%
  465. \epsfclipoff
  466. %
  467. \def\epsfsetgraph#1{%
  468.    \epsfrsize=\epsfury\pspoints
  469.    \advance\epsfrsize by-\epsflly\pspoints
  470.    \epsftsize=\epsfurx\pspoints
  471.    \advance\epsftsize by-\epsfllx\pspoints
  472. %
  473. %   If `epsfxsize' is 0, we default to the natural size of the picture.
  474. %   Otherwise we scale the graph to be \epsfxsize wide.
  475. %
  476.    \epsfxsize\epsfsize\epsftsize\epsfrsize
  477.    \ifnum\epsfxsize=0 \ifnum\epsfysize=0
  478.       \epsfxsize=\epsftsize \epsfysize=\epsfrsize
  479.       \epsfrsize=0pt
  480. %
  481. %   We have a sticky problem here:  TeX doesn't do floating point arithmetic!
  482. %   Our goal is to compute y = rx/t. The following loop does this reasonably
  483. %   fast, with an error of at most about 16 sp (about 1/4000 pt).
  484.      \else\epsftmp=\epsftsize \divide\epsftmp\epsfrsize
  485.        \epsfxsize=\epsfysize \multiply\epsfxsize\epsftmp
  486.        \multiply\epsftmp\epsfrsize \advance\epsftsize-\epsftmp
  487.        \epsftmp=\epsfysize
  488.        \loop \advance\epsftsize\epsftsize \divide\epsftmp 2
  489.        \ifnum\epsftmp>0
  490.           \ifnum\epsftsize<\epsfrsize\else
  491.              \advance\epsftsize-\epsfrsize \advance\epsfxsize\epsftmp \fi
  492.        \repeat
  493.        \epsfrsize=0pt
  494.      \fi
  495.    \else \ifnum\epsfysize=0
  496.      \epsftmp=\epsfrsize \divide\epsftmp\epsftsize
  497.      \epsfysize=\epsfxsize \multiply\epsfysize\epsftmp   
  498.      \multiply\epsftmp\epsftsize \advance\epsfrsize-\epsftmp
  499.      \epsftmp=\epsfxsize
  500.      \loop \advance\epsfrsize\epsfrsize \divide\epsftmp 2
  501.      \ifnum\epsftmp>0
  502.         \ifnum\epsfrsize<\epsftsize\else
  503.            \advance\epsfrsize-\epsftsize \advance\epsfysize\epsftmp \fi
  504.      \repeat
  505.      \epsfrsize=0pt
  506.     \else
  507.      \epsfrsize=\epsfysize
  508.     \fi
  509.    \fi
  510. %
  511. %  Finally, we make the vbox and stick in a \special that dvips can parse.
  512. %
  513.    \ifepsfverbose\message{#1: width=\the\epsfxsize, height=\the\epsfysize}\fi
  514.    \epsftmp=10\epsfxsize \divide\epsftmp\pspoints
  515.    \vbox to\epsfysize{\vfil\hbox to\epsfxsize{%
  516.       \ifnum\epsfrsize=0\relax
  517.         \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space
  518.              llx=\epsfllx\space lly=\epsflly\space
  519.              urx=\epsfurx\space ury=\epsfury\space rwi=\number\epsftmp
  520.              \epsfclipstring}%
  521.       \else
  522.         \epsfrsize=10\epsfysize \divide\epsfrsize\pspoints
  523.         \special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space
  524.              llx=\epsfllx\space lly=\epsflly\space
  525.              urx=\epsfurx\space ury=\epsfury\space rwi=\number\epsftmp\space
  526.              rhi=\number\epsfrsize \epsfclipstring}%
  527.       \fi
  528.       \hfil}}%
  529. \global\epsfxsize=0pt\global\epsfysize=0pt}%
  530. %
  531. %   We still need to define the tricky \epsfaux macro. This requires
  532. %   a couple of magic constants for comparison purposes.
  533. %
  534. {\catcode`\%=12 \global\let\epsfpercent=%\global\def\epsfbblit{%BoundingBox}}%
  535. %
  536. %   So we're ready to check for `%BoundingBox:' and to grab the
  537. %   values if they are found.
  538. %
  539. \long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
  540.    \def\testit{#2}\ifx\testit\epsfbblit
  541.       \epsfgrab #3 . . . \\%
  542.       \epsffileokfalse
  543.       \global\epsfbbfoundtrue
  544.    \fi\else\ifx#1\par\else\epsffileokfalse\fi\fi}%
  545. %
  546. %   Here we grab the values and stuff them in the appropriate definitions.
  547. %
  548. \def\epsfempty{}%
  549. \def\epsfgrab #1 #2 #3 #4 #5\\{%
  550. \global\def\epsfllx{#1}\ifx\epsfllx\epsfempty
  551.       \epsfgrab #2 #3 #4 #5 .\\\else
  552.    \global\def\epsflly{#2}%
  553.    \global\def\epsfurx{#3}\global\def\epsfury{#4}\fi}%
  554. %
  555. %   We default the epsfsize macro.
  556. %
  557. \def\epsfsize#1#2{\epsfxsize}
  558. %
  559. %   Finally, another definition for compatibility with older macros.
  560. %
  561. \let\epsffile=\epsfbox
  562.  
  563. %
  564. %% SPQR 12.91 handling of errors using standard LaTeX error
  565. %% mechanism. In case we are plain TeX we first define the
  566. %% error routines...
  567. \ifx\undefined\@latexerr
  568.         \newlinechar`\^^J
  569.         \def\@spaces{\space\space\space\space}%
  570.         \def\@latexerr#1#2{%
  571.         \edef\@tempc{#2}\expandafter\errhelp\expandafter{\@tempc}%
  572.         \typeout{Error. \space see a manual for explanation.^^J
  573.          \space\@spaces\@spaces\@spaces Type \space H <return> \space for
  574.          immediate help.}\errmessage{#1}}%
  575. \fi
  576. %------------------------
  577. %% a couple of LaTeX error messages
  578. \def\@whattodo{You tried to include a PostScript figure which
  579. cannot be found^^JIf you press return to carry on anyway,^^J
  580. The failed name will be printed in place of the figure.^^J
  581. or type X to quit}%
  582. \def\@whattodobb{You tried to include a PostScript figure which
  583. has no^^Jbounding box, and you supplied none.^^J
  584. If you press return to carry on anyway,^^J
  585. The failed name will be printed in place of the figure.^^J
  586. or type X to quit}%
  587. %------------------------
  588. %
  589. %------------------------------------------------------------------------
  590. %------------------------------------------------------------------------
  591. %%% @psdo control structure -- similar to Latex @for.
  592. %%% I redefined these with different names so that psfig can
  593. %%% be used with TeX as well as LaTeX, and so that it will not
  594. %%% be vunerable to future changes in LaTeX's internal
  595. %%% control structure,
  596. %
  597. \def\@nnil{\@nil}%
  598. \def\@empty{}%
  599. \def\@psdonoop#1\@@#2#3{}%
  600. \def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
  601.     \expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi}%
  602. \def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
  603.        #5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi}%
  604. \def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
  605.        \let\@nextwhile=\@psdonoop \else
  606.       #4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}}%
  607. \def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
  608.     \@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi}%
  609. \def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
  610.        \let\@nextwhile=\@psdonoop \else
  611.       #4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}}%
  612. %%%
  613. %
  614. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  615. %%% file reading stuff from epsf.tex
  616. %%%   EPSF.TEX macro file:
  617. %%%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
  618. %%%   Revised by Don Knuth, 3 Jan 1990.
  619. %%%   Revised by Tomas Rokicki to accept bounding boxes with no
  620. %%%      space after the colon, 18 Jul 1990.
  621. %%%   Portions modified/removed for use in PSFIG package by
  622. %%%      J. Daniel Smith, 9 October 1990.
  623. %%%   Just the bit which knows about (atend) as a BoundingBox
  624. %
  625. %%%    hacked back a bit by SPQR 12/91
  626. %
  627. \long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
  628.    \def\testit{#2}\ifx\testit\epsfbblit
  629.         \@atendfalse
  630.         \epsf@atend #3 . \\%
  631.         \if@atend
  632.            \if@verbose
  633.                 \typeout{epsfig: found `(atend)'; continuing search}%
  634.            \fi
  635.         \else
  636.                 \epsfgrab #3 . . . \\%
  637.                 \epsffileokfalse\global\no@bbfalse
  638.                 \global\epsfbbfoundtrue
  639.         \fi
  640.    \fi\fi}%
  641. %
  642. %%% Determine if the stuff following the %%BoundingBox is `(atend)'
  643. %%% J. Daniel Smith.  Copied from \epsf@grab above.
  644. %
  645. \def\epsf@atendlit{(atend)}
  646. %
  647. \def\epsf@atend #1 #2 #3\\{%
  648.    \def\epsf@tmp{#1}\ifx\epsf@tmp\empty
  649.       \epsf@atend #2 #3 .\\\else
  650.    \ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi}%
  651.  
  652.  
  653. %%% End of file reading stuff from epsf.tex
  654. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  655.  
  656. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  657. %%% trigonometry stuff from "trig.tex"
  658. \chardef\trig@letter = 11
  659. \chardef\other = 12
  660.  
  661. \newif\ifdebug %%% turn me on to see TeX hard at work ...
  662. \newif\ifc@mpute %%% don't need to compute some values
  663. \newif\if@atend
  664. \c@mputetrue % but assume that we do
  665.  
  666. \let\then = \relax
  667. \def\r@dian{pt }%
  668. \let\r@dians = \r@dian
  669. \let\dimensionless@nit = \r@dian
  670. \let\dimensionless@nits = \dimensionless@nit
  671. \def\internal@nit{sp }%
  672. \let\internal@nits = \internal@nit
  673. \newif\ifstillc@nverging
  674. \def \Mess@ge #1{\ifdebug \then \message {#1} \fi}%
  675.  
  676. { %%% Things that need abnormal catcodes %%%
  677.         \catcode `\@ = \trig@letter
  678.         \gdef \nodimen {\expandafter \n@dimen \the \dimen}%
  679.         \gdef \term #1 #2 #3%
  680.                {\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value)
  681.                 \edef \t@@ {\expandafter \n@dimen \the #2\r@dian}%
  682.                                    %%% freeze parameter 2 (dimen, by value)
  683.                 \t@rm {\t@} {\t@@} {#3}%
  684.                }%
  685.         \gdef \t@rm #1 #2 #3%
  686.                {{%
  687.                 \count 0 = 0
  688.                 \dimen 0 = 1 \dimensionless@nit
  689.                 \dimen 2 = #2\relax
  690.                 \Mess@ge {Calculating term #1 of \nodimen 2}%
  691.                 \loop
  692.                 \ifnum  \count 0 < #1
  693.                 \then   \advance \count 0 by 1
  694.                         \Mess@ge {Iteration \the \count 0 \space}%
  695.                         \Multiply \dimen 0 by {\dimen 2}%
  696.                         \Mess@ge {After multiplication, term = \nodimen 0}%
  697.                         \Divide \dimen 0 by {\count 0}%
  698.                         \Mess@ge {After division, term = \nodimen 0}%
  699.                 \repeat
  700.                 \Mess@ge {Final value for term #1 of
  701.                                 \nodimen 2 \space is \nodimen 0}%
  702.                 \xdef \Term {#3 = \nodimen 0 \r@dians}%
  703.                 \aftergroup \Term
  704.                }}%
  705.         \catcode `\p = \other
  706.         \catcode `\t = \other
  707.         \gdef \n@dimen #1pt{#1} %%% throw away the ``pt''
  708. }%
  709.  
  710. \def \Divide #1by #2{\divide #1 by #2} %%% just a synonym
  711.  
  712. \def \Multiply #1by #2%%% allows division of a dimen by a dimen
  713.        {{%%% should really freeze parameter 2 (dimen, passed by value)
  714.         \count 0 = #1\relax
  715.         \count 2 = #2\relax
  716.         \count 4 = 65536
  717.         \Mess@ge {Before scaling, count 0 = \the \count 0 \space and
  718.                         count 2 = \the \count 2}%
  719.         \ifnum  \count 0 > 32767 %%% do our best to avoid overflow
  720.         \then   \divide \count 0 by 4
  721.                 \divide \count 4 by 4
  722.         \else   \ifnum  \count 0 < -32767
  723.                 \then   \divide \count 0 by 4
  724.                         \divide \count 4 by 4
  725.                 \else
  726.                 \fi
  727.         \fi
  728.         \ifnum  \count 2 > 32767 %%% while retaining reasonable accuracy
  729.         \then   \divide \count 2 by 4
  730.                 \divide \count 4 by 4
  731.         \else   \ifnum  \count 2 < -32767
  732.                 \then   \divide \count 2 by 4
  733.                         \divide \count 4 by 4
  734.                 \else
  735.                 \fi
  736.         \fi
  737.         \multiply \count 0 by \count 2
  738.         \divide \count 0 by \count 4
  739.         \xdef \product {#1 = \the \count 0 \internal@nits}%
  740.         \aftergroup \product
  741.        }}%
  742.  
  743. \def\r@duce{\ifdim\dimen0 > 90\r@dian \then   % sin(x) = sin(180-x)
  744.                 \multiply\dimen0 by -1
  745.                 \advance\dimen0 by 180\r@dian
  746.                 \r@duce
  747.             \else \ifdim\dimen0 < -90\r@dian \then  % sin(x) = sin(360+x)
  748.                 \advance\dimen0 by 360\r@dian
  749.                 \r@duce
  750.                 \fi
  751.             \fi}%
  752.  
  753. \def\Sine#1%
  754.        {{%
  755.         \dimen 0 = #1 \r@dian
  756.         \r@duce
  757.         \ifdim\dimen0 = -90\r@dian \then
  758.            \dimen4 = -1\r@dian
  759.            \c@mputefalse
  760.         \fi
  761.         \ifdim\dimen0 = 90\r@dian \then
  762.            \dimen4 = 1\r@dian
  763.            \c@mputefalse
  764.         \fi
  765.         \ifdim\dimen0 = 0\r@dian \then
  766.            \dimen4 = 0\r@dian
  767.            \c@mputefalse
  768.         \fi
  769. %
  770.         \ifc@mpute \then
  771.                 % convert degrees to radians
  772.                 \divide\dimen0 by 180
  773.                 \dimen0=3.141592654\dimen0
  774. %
  775.                 \dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant
  776.                 \divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2
  777.                 \Mess@ge {Sin: calculating Sin of \nodimen 0}%
  778.                 \count 0 = 1 %%% see power-series expansion for sine
  779.                 \dimen 2 = 1 \r@dian %%% ditto
  780.                 \dimen 4 = 0 \r@dian %%% ditto
  781.                 \loop
  782.                         \ifnum  \dimen 2 = 0 %%% then we've done
  783.                         \then   \stillc@nvergingfalse
  784.                         \else   \stillc@nvergingtrue
  785.                         \fi
  786.                         \ifstillc@nverging %%% then calculate next term
  787.                         \then   \term {\count 0} {\dimen 0} {\dimen 2}%
  788.                                 \advance \count 0 by 2
  789.                                 \count 2 = \count 0
  790.                                 \divide \count 2 by 2
  791.                                 \ifodd  \count 2 %%% signs alternate
  792.                                 \then   \advance \dimen 4 by \dimen 2
  793.                                 \else   \advance \dimen 4 by -\dimen 2
  794.                                 \fi
  795.                 \repeat
  796.         \fi
  797.                         \xdef \sine {\nodimen 4}%
  798.        }}%
  799.  
  800. %%% Now the Cosine can be calculated easily by calling \Sine:
  801. %%%  cos(x) = sin(90-x)
  802. \def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
  803.                              \edef\Savesine{\sine}\fi
  804.         {\dimen0=#1\r@dian\multiply\dimen0 by -1
  805.          \advance\dimen0 by 90\r@dian
  806.          \Sine{\nodimen 0}%
  807.          \xdef\cosine{\sine}%
  808.          \xdef\sine{\Savesine}}}
  809. %%% end of trig stuff
  810. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  811. %
  812. \def\psdraft{\def\@psdraft{0}}%
  813. \def\psfull{\def\@psdraft{1}}%
  814. \psfull
  815. \newif\if@compress
  816. \def\pscompress{\@compresstrue}
  817. \def\psnocompress{\@compressfalse}
  818. \@compressfalse
  819. \newif\if@scalefirst
  820. \def\psscalefirst{\@scalefirsttrue}%
  821. \def\psrotatefirst{\@scalefirstfalse}%
  822. \psrotatefirst
  823. %
  824. \newif\if@draftbox
  825. \def\psnodraftbox{\@draftboxfalse}%
  826. \@draftboxtrue
  827. %
  828. \newif\if@noisy
  829. \@noisyfalse
  830. \newif\ifno@bb
  831. %%% These are for the option list.
  832. %%% A specification of the form a = b maps to calling \@p@@sa{b}%
  833. \newif\if@bbllx
  834. \newif\if@bblly
  835. \newif\if@bburx
  836. \newif\if@bbury
  837. \newif\if@height
  838. \newif\if@width
  839. \newif\if@rheight
  840. \newif\if@rwidth
  841. \newif\if@angle
  842. \newif\if@clip
  843. \newif\if@verbose
  844. \newif\if@prologfile
  845. \def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}}%
  846. \def\@p@@sclip#1{\@cliptrue}%
  847. %
  848. \newif\ifepsfig@dos  % only single suffix possible
  849. \def\epsfigdos{\epsfig@dostrue}%
  850. \epsfig@dosfalse
  851. %
  852. \def\ParseName#1{\expandafter\@Parse#1}%
  853. \def\@Parse#1.#2:{\gdef\BaseName{#1}\gdef\FileType{#2}}%
  854.  
  855. \def\@p@@sfile#1{%
  856.   \ifepsfig@dos
  857.      \ParseName{#1:}%
  858.   \else
  859.      \gdef\BaseName{#1}\gdef\FileType{}%
  860.   \fi
  861.   \def\@p@sfile{NO FILE: #1}%
  862.   \def\@p@sfilefinal{NO FILE: #1}%
  863.   \openin1=#1
  864.   \ifeof1\closein1\openin1=\BaseName.bb
  865.     \ifeof1\closein1
  866.       \if@bbllx                 % No postscript file but bb given explicitly.
  867.         \if@bblly\if@bburx\if@bbury
  868.           \def\@p@sfile{#1}%
  869.           \def\@p@sfilefinal{#1}%
  870.         \fi\fi\fi
  871.       \else                     % No bounding box found.
  872.         \@latexerr{ERROR. PostScript file #1 not found}\@whattodo
  873.         \@p@@sbbllx{100bp}%
  874.         \@p@@sbblly{100bp}%
  875.         \@p@@sbburx{200bp}%
  876.         \@p@@sbbury{200bp}%
  877.         \psdraft
  878.       \fi
  879.     \else                       % Postscript file is compressed.
  880.       \closein1%
  881.       \edef\@p@sfile{\BaseName.bb}%
  882.       \typeout{using BB from \@p@sfile}%
  883.       \ifnum\fig@driver=3
  884.         \edef\@p@sfilefinal{\BaseName.pcx}%
  885.       \else
  886.         \ifepsfig@dos
  887.           \edef\@p@sfilefinal{"`gunzip -c `texfind \BaseName.{z,Z,gz}"}%
  888.         \else
  889.           \edef\@p@sfilefinal{"`epsfig \if@compress-c \fi#1"}%          
  890.         \fi
  891.       \fi
  892.     \fi
  893.   \else\closein1                % Postscript file is not compressed.
  894.     \edef\@p@sfile{#1}%
  895.     \if@compress  
  896.       \edef\@p@sfilefinal{"`epsfig -c #1"}%
  897.     \else
  898.       \edef\@p@sfilefinal{#1}%
  899.     \fi
  900.   \fi%
  901. }
  902.  
  903. % alternative syntax: figure=
  904. \let\@p@@sfigure\@p@@sfile
  905. %
  906. \def\@p@@sbbllx#1{%
  907.                                             \@bbllxtrue
  908.                 \ps@dimcent=#1
  909.                 \edef\@p@sbbllx{\number\ps@dimcent}%
  910.                 \divide\ps@dimcent by65536
  911.                 \global\edef\epsfllx{\number\ps@dimcent}%
  912. }%
  913. \def\@p@@sbblly#1{%
  914.                 \@bbllytrue
  915.                 \ps@dimcent=#1
  916.                 \edef\@p@sbblly{\number\ps@dimcent}%
  917.                 \divide\ps@dimcent by65536
  918.                 \global\edef\epsflly{\number\ps@dimcent}%
  919. }%
  920. \def\@p@@sbburx#1{%
  921.                 \@bburxtrue
  922.                 \ps@dimcent=#1
  923.                 \edef\@p@sbburx{\number\ps@dimcent}%
  924.                 \divide\ps@dimcent by65536
  925.                 \global\edef\epsfurx{\number\ps@dimcent}%
  926. }%
  927. \def\@p@@sbbury#1{%
  928.                 \@bburytrue
  929.                 \ps@dimcent=#1
  930.                 \edef\@p@sbbury{\number\ps@dimcent}%
  931.                 \divide\ps@dimcent by65536
  932.                 \global\edef\epsfury{\number\ps@dimcent}%
  933. }%
  934. \def\@p@@sheight#1{%
  935.                 \@heighttrue
  936.                 \global\epsfysize=#1
  937.                 \ps@dimcent=#1
  938.                 \edef\@p@sheight{\number\ps@dimcent}%
  939. }%
  940. \def\@p@@swidth#1{%
  941.                 \@widthtrue
  942.                 \global\epsfxsize=#1
  943.                 \ps@dimcent=#1
  944.                 \edef\@p@swidth{\number\ps@dimcent}% 
  945. }%
  946. \def\@p@@srheight#1{%
  947.                 \@rheighttrue\use@psfigtrue
  948.                 \ps@dimcent=#1
  949.                 \edef\@p@srheight{\number\ps@dimcent}%
  950. }%
  951. \def\@p@@srwidth#1{%
  952.                 \@rwidthtrue\use@psfigtrue
  953.                 \ps@dimcent=#1
  954.                 \edef\@p@srwidth{\number\ps@dimcent}%
  955. }%
  956. \def\@p@@sangle#1{%
  957.                 \use@psfigtrue
  958.                 \@angletrue
  959.                 \edef\@p@sangle{#1}%
  960. }%
  961. \def\@p@@ssilent#1{%
  962.                 \@verbosefalse
  963. }%
  964. \def\@p@@snoisy#1{%
  965.                 \@verbosetrue
  966. }%
  967. \def\@cs@name#1{\csname #1\endcsname}%
  968. \def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}}%
  969. %
  970. %%% initialize the defaults (size the size of the figure)
  971. %
  972. \def\ps@init@parms{%
  973.                 \@bbllxfalse \@bbllyfalse
  974.                 \@bburxfalse \@bburyfalse
  975.                 \@heightfalse \@widthfalse
  976.                 \@rheightfalse \@rwidthfalse
  977.                 \def\@p@sbbllx{}\def\@p@sbblly{}%
  978.                 \def\@p@sbburx{}\def\@p@sbbury{}%
  979.                 \def\@p@sheight{}\def\@p@swidth{}%
  980.                 \def\@p@srheight{}\def\@p@srwidth{}%
  981.                 \def\@p@sangle{0}%
  982.                 \def\@p@sfile{}%
  983.                 \@prologfilefalse
  984.                 \def\@sc{}%
  985.                 \if@noisy
  986.                         \@verbosetrue
  987.                 \else
  988.                         \@verbosefalse
  989.                 \fi
  990.                 \@clipfalse
  991. }%
  992. %
  993. %%% Go through the options setting things up.
  994. %
  995. \def\parse@ps@parms#1{%
  996.                 \@psdo\@psfiga:=#1\do
  997.                    {\expandafter\@setparms\@psfiga,}%
  998. \if@prologfile
  999. \special{header=\@prologfileval}%
  1000. \fi
  1001. }%
  1002. %
  1003. %%% Compute bb height and width
  1004. %
  1005. \def\bb@missing{%
  1006.         \if@verbose
  1007.             \typeout{psfig: searching \@p@sfile \space  for bounding box}%
  1008.         \fi
  1009.         \epsfgetbb{\@p@sfile}%
  1010.         \ifepsfbbfound
  1011.             \ps@dimcent=\epsfllx bp\edef\@p@sbbllx{\number\ps@dimcent}%
  1012.             \ps@dimcent=\epsflly bp\edef\@p@sbblly{\number\ps@dimcent}%
  1013.             \ps@dimcent=\epsfurx bp\edef\@p@sbburx{\number\ps@dimcent}%
  1014.             \ps@dimcent=\epsfury bp\edef\@p@sbbury{\number\ps@dimcent}%
  1015.         \else
  1016.             \epsfbbfoundfalse
  1017.         \fi
  1018. }
  1019. %
  1020. % rotate point (#1,#2) about (0,0).
  1021. % The sine and cosine of the angle are already stored in \sine and
  1022. % \cosine.  The result is placed in (\p@intvaluex, \p@intvaluey).
  1023. \newdimen\p@intvaluex
  1024. \newdimen\p@intvaluey
  1025. \def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp
  1026. %               calculate x' = x \cos\theta - y \sin\theta
  1027.                   \global\p@intvaluex=\cosine\dimen0
  1028.                   \dimen3=\sine\dimen1
  1029.                   \global\advance\p@intvaluex by -\dimen3
  1030. %               calculate y' = x \sin\theta + y \cos\theta
  1031.                   \global\p@intvaluey=\sine\dimen0
  1032.                   \dimen3=\cosine\dimen1
  1033.                   \global\advance\p@intvaluey by \dimen3
  1034.                   }}%
  1035. \def\compute@bb{%
  1036.                 \epsfbbfoundfalse
  1037.                 \if@bbllx\epsfbbfoundtrue\fi
  1038.                 \if@bblly\epsfbbfoundtrue\fi
  1039.                 \if@bburx\epsfbbfoundtrue\fi
  1040.                 \if@bbury\epsfbbfoundtrue\fi
  1041.                 \ifepsfbbfound\else\bb@missing\fi
  1042.                 \ifepsfbbfound\else
  1043.                 \@latexerr{ERROR. cannot locate BoundingBox}\@whattodobb
  1044.                         \@p@@sbbllx{100bp}%
  1045.                         \@p@@sbblly{100bp}%
  1046.                         \@p@@sbburx{200bp}%
  1047.                         \@p@@sbbury{200bp}%
  1048.                         \no@bbtrue
  1049.                         \psdraft
  1050.                 \fi
  1051.                 %
  1052. %
  1053. % store height/width of original (unrotated) bounding box
  1054.                 \count203=\@p@sbburx
  1055.                 \count204=\@p@sbbury
  1056.                 \advance\count203 by -\@p@sbbllx
  1057.                 \advance\count204 by -\@p@sbblly
  1058.                 \edef\ps@bbw{\number\count203}%
  1059.                 \edef\ps@bbh{\number\count204}%
  1060.                  \edef\@bbw{\number\count203}%
  1061.                 \edef\@bbh{\number\count204}%
  1062.                \if@angle
  1063.                         \Sine{\@p@sangle}\Cosine{\@p@sangle}%
  1064.  
  1065. {\ps@dimcent=\maxdimen\xdef\r@p@sbbllx{\number\ps@dimcent}%
  1066.  
  1067. \xdef\r@p@sbblly{\number\ps@dimcent}%
  1068.  
  1069. \xdef\r@p@sbburx{-\number\ps@dimcent}%
  1070.  
  1071. \xdef\r@p@sbbury{-\number\ps@dimcent}}%
  1072. %
  1073. % Need to rotate all four points and take the X-Y extremes of the new
  1074. % points as the new bounding box.
  1075.                         \def\minmaxtest{%
  1076.                            \ifnum\number\p@intvaluex<\r@p@sbbllx
  1077.                               \xdef\r@p@sbbllx{\number\p@intvaluex}\fi
  1078.                            \ifnum\number\p@intvaluex>\r@p@sbburx
  1079.                               \xdef\r@p@sbburx{\number\p@intvaluex}\fi
  1080.                            \ifnum\number\p@intvaluey<\r@p@sbblly
  1081.                               \xdef\r@p@sbblly{\number\p@intvaluey}\fi
  1082.                            \ifnum\number\p@intvaluey>\r@p@sbbury
  1083.                               \xdef\r@p@sbbury{\number\p@intvaluey}\fi
  1084.                            }%
  1085. %                       lower left
  1086.                         \rotate@{\@p@sbbllx}{\@p@sbblly}%
  1087.                         \minmaxtest
  1088. %                       upper left
  1089.                         \rotate@{\@p@sbbllx}{\@p@sbbury}%
  1090.                         \minmaxtest
  1091. %                       lower right
  1092.                         \rotate@{\@p@sbburx}{\@p@sbblly}%
  1093.                         \minmaxtest
  1094. %                       upper right
  1095.                         \rotate@{\@p@sbburx}{\@p@sbbury}%
  1096.                         \minmaxtest
  1097.  
  1098. \edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly}%
  1099.  
  1100. \edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury}%
  1101.                 \fi
  1102.                 \count203=\@p@sbburx
  1103.                 \count204=\@p@sbbury
  1104.                 \advance\count203 by -\@p@sbbllx
  1105.                 \advance\count204 by -\@p@sbblly
  1106.                 \edef\@bbw{\number\count203}%
  1107.                 \edef\@bbh{\number\count204}%
  1108. }%
  1109. %
  1110. % \in@hundreds performs #1 * (#2 / #3) correct to the hundreds,
  1111. %       then leaves the result in @result
  1112. %
  1113. \def\in@hundreds#1#2#3{\count240=#2 \count241=#3
  1114.                      \count100=\count240        % 100 is first digit #2/#3
  1115.                      \divide\count100 by \count241
  1116.                      \count101=\count100
  1117.                      \multiply\count101 by \count241
  1118.                      \advance\count240 by -\count101
  1119.                      \multiply\count240 by 10
  1120.                      \count101=\count240        %101 is second digit of #2/#3
  1121.                      \divide\count101 by \count241
  1122.                      \count102=\count101
  1123.                      \multiply\count102 by \count241
  1124.                      \advance\count240 by -\count102
  1125.                      \multiply\count240 by 10
  1126.                      \count102=\count240        % 102 is the third digit
  1127.                      \divide\count102 by \count241
  1128.                      \count200=#1\count205=0
  1129.                      \count201=\count200
  1130.                         \multiply\count201 by \count100
  1131.                         \advance\count205 by \count201
  1132.                      \count201=\count200
  1133.                         \divide\count201 by 10
  1134.                         \multiply\count201 by \count101
  1135.                         \advance\count205 by \count201
  1136.                         %
  1137.                      \count201=\count200
  1138.                         \divide\count201 by 100
  1139.                         \multiply\count201 by \count102
  1140.                         \advance\count205 by \count201
  1141.                         %
  1142.                      \edef\@result{\number\count205}%
  1143. }%
  1144. \def\compute@wfromh{%
  1145.                 % computing : width = height * (bbw / bbh)
  1146.                 \in@hundreds{\@p@sheight}{\@bbw}{\@bbh}%
  1147.                 \edef\@p@swidth{\@result}%
  1148. }%
  1149. \def\compute@hfromw{%
  1150.                 % computing : height = width * (bbh / bbw)
  1151.                 \in@hundreds{\@p@swidth}{\@bbh}{\@bbw}%
  1152.                 \edef\@p@sheight{\@result}%
  1153. }%
  1154. \def\compute@handw{%
  1155.                 \if@height
  1156.                         \if@width
  1157.                         \else
  1158.                                 \compute@wfromh
  1159.                         \fi
  1160.                 \else
  1161.                         \if@width
  1162.                                 \compute@hfromw
  1163.                         \else
  1164.                                 \edef\@p@sheight{\@bbh}%
  1165.                                 \edef\@p@swidth{\@bbw}%
  1166.                         \fi
  1167.                 \fi
  1168. }%
  1169. \def\compute@resv{%
  1170.                 \if@rheight \else \edef\@p@srheight{\@p@sheight} \fi
  1171.                 \if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi
  1172. }%
  1173. %
  1174. % Compute any missing values
  1175. \def\compute@sizes{%
  1176.         \if@scalefirst\if@angle
  1177. % at this point the bounding box has been adjsuted correctly for
  1178. % rotation.  PSFIG does all of its scaling using \@bbh and \@bbw.  If
  1179. % a width= or height= was specified along with \psscalefirst, then the
  1180. % width=/height= value needs to be adjusted to match the new (rotated)
  1181. % bounding box size (specifed in \@bbw and \@bbh).
  1182. %    \ps@bbw       width=
  1183. %    -------  =  ----------
  1184. %    \@bbw       new width=
  1185. % so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the
  1186. % width of the original (unrotated) bounding box.
  1187.         \if@width
  1188.            \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw}%
  1189.            \edef\@p@swidth{\@result}%
  1190.         \fi
  1191.         \if@height
  1192.            \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh}%
  1193.            \edef\@p@sheight{\@result}%
  1194.         \fi
  1195.         \fi\fi
  1196.         \compute@handw
  1197.         \compute@resv
  1198. }
  1199. %
  1200.  
  1201. %------------------------------------------------------------------
  1202. %%% by the way, possible parameters to the PSfile= command in dvips are:
  1203. %%%                    llx
  1204. %%%                    lly
  1205. %%%                    urx
  1206. %%%                    ury
  1207. %%%                    rwi
  1208. %       hoffset The horizontal offset (default 0)
  1209. %       voffset The vertical offset (default 0)
  1210. %       hsize   The horizontal clipping size (default 612)
  1211. %       vsize   The vertical clipping size (default 792)
  1212. %       hscale  The horizontal scaling factor (default 100)
  1213. %       vscale  The vertical scaling factor (default 100)
  1214. %       angle   The rotation (default 0)
  1215. %------------------------------------------------------------------
  1216. \long\def\graphic@verb#1{\def\next{#1}%
  1217.   {\expandafter\graphic@strip\meaning\next}}
  1218. \def\graphic@strip#1>{}
  1219. \def\graphic@zapspace#1{%
  1220.   #1\ifx\graphic@zapspace#1\graphic@zapspace%
  1221.   \else\expandafter\graphic@zapspace%
  1222.   \fi}
  1223. \def\psfig#1{%
  1224. \edef\@tempa{\graphic@zapspace#1{}}%
  1225. \ifvmode\leavevmode\fi\vbox {%
  1226.         %
  1227.         \ps@init@parms
  1228.         \parse@ps@parms{\@tempa}%
  1229.         %
  1230.         \ifnum\@psdraft=1
  1231.                 \typeout{[\@p@sfilefinal]}%
  1232.                 \if@verbose
  1233.                         \typeout{epsfig: using PSFIG macros}%
  1234.                 \fi
  1235.                 \psfig@method
  1236.         \else
  1237.                 \epsfig@draft
  1238.         \fi
  1239. }
  1240. }%
  1241. \def\graphic@zapspace#1{%
  1242.   #1\ifx\graphic@zapspace#1\graphic@zapspace%
  1243.   \else\expandafter\graphic@zapspace%
  1244.   \fi}
  1245. \def\epsfig#1{%
  1246. \edef\@tempa{\graphic@zapspace#1{}}%
  1247. \ifvmode\leavevmode\fi\vbox {%
  1248.         %
  1249.         \ps@init@parms
  1250.         \parse@ps@parms{\@tempa}%
  1251.         %
  1252.         \ifnum\@psdraft=1
  1253.           \if@angle\use@psfigtrue\fi
  1254.                 \ifuse@psfig
  1255.                         \if@verbose
  1256.                                 \typeout{epsfig: using PSFIG macros}%
  1257.                         \fi
  1258.                         \psfig@method
  1259.                 \else
  1260.                         \if@verbose
  1261.                                 \typeout{epsfig: using EPSF macros}%
  1262.                         \fi
  1263.                         \epsf@method
  1264.                 \fi
  1265.         \else
  1266.                 \epsfig@draft
  1267.         \fi
  1268. }%
  1269. }%
  1270.  
  1271.  
  1272. \def\epsf@method{%
  1273.         \epsfbbfoundfalse
  1274.         \if@bbllx\epsfbbfoundtrue\fi
  1275.         \if@bblly\epsfbbfoundtrue\fi
  1276.         \if@bburx\epsfbbfoundtrue\fi
  1277.         \if@bbury\epsfbbfoundtrue\fi
  1278.         \ifepsfbbfound\else\epsfgetbb{\@p@sfile}\fi
  1279.         \ifepsfbbfound
  1280.            \typeout{<\@p@sfilefinal>}%
  1281.            \epsfig@gofer
  1282.         \else
  1283.           \@latexerr{ERROR - Cannot locate BoundingBox}\@whattodobb
  1284.           \@p@@sbbllx{100bp}%
  1285.           \@p@@sbblly{100bp}%
  1286.           \@p@@sbburx{200bp}%
  1287.           \@p@@sbbury{200bp}%
  1288.                 \count203=\@p@sbburx
  1289.                 \count204=\@p@sbbury
  1290.                 \advance\count203 by -\@p@sbbllx
  1291.                 \advance\count204 by -\@p@sbblly
  1292.                 \edef\@bbw{\number\count203}%
  1293.                 \edef\@bbh{\number\count204}%
  1294.           \compute@sizes
  1295.           \epsfig@@draft
  1296.        \fi
  1297. }%
  1298. \def\psfig@method{%
  1299.         \compute@bb
  1300.         \ifepsfbbfound
  1301.           \compute@sizes
  1302.           \psfig@start
  1303.           % Create the vbox to reserve the space for the figure%
  1304.           \vbox to \@p@srheight sp{\hbox to \@p@srwidth 
  1305.             sp{\hss}\vss\psfig@end}%
  1306.         \else
  1307.            \epsfig@draft
  1308.         \fi
  1309. }%
  1310. %
  1311. % draft figure, just reserve the space and print the
  1312. % path name.
  1313. \def\epsfig@draft{\compute@bb\compute@sizes\epsfig@@draft}%
  1314. %
  1315. \def\epsfig@@draft{%
  1316. \typeout{<(draft only) \@p@sfilefinal>}%
  1317. \if@draftbox
  1318.         % Verbose draft: print file name in box
  1319.         \hbox{{\fboxsep0pt\fbox{\vbox to \@p@srheight sp{%
  1320.         \vss\hbox to \@p@srwidth sp{ \hss 
  1321.            \expandafter\Literally\@p@sfilefinal\@nil
  1322.                           \hss }\vss
  1323.         }}}}%
  1324. \else
  1325.         % Non-verbose draft
  1326.         \vbox to \@p@srheight sp{%
  1327.         \vss\hbox to \@p@srwidth sp{\hss}\vss}%
  1328. \fi
  1329. }%
  1330. \def\Literally#1\@nil{{\tt\graphic@verb{#1}}}
  1331. \def\psfigdriver#1{\typeout{^J WARNING: dont use psfigdriver!
  1332.  use a class option!^J}}
  1333. \endinput
  1334.  
  1335.  
  1336.